package com.hezhiqin.lock;

/**
 * @program: homeWork
 * @description:
 * @author: hezhiqin
 * @create: 2019-12-06 22:06
 */
public class DeadLockDemo {
    public synchronized void demo() {
        System.out.println("begin:demo");
        demo2();
    }

    public void demo2()  {
        System.out.println("begin:demo1");
        synchronized (this) {
            try {
                System.out.println("begin:demo3");
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        DeadLockDemo rd = new DeadLockDemo();
        new Thread(rd::demo).start();
    }
}
